{% extends "base.html" %}
{% block page_title %}Update Project{% endblock %}
{% load static %}
{% load render_bundle from webpack_loader %}

{% block content %}
<div class="row">
  <div class="col-md-8 col-md-offset-2">
    <div class="card">
      <div class="cardface">
        {{ form.media.css }}
        <form action="." method="post" enctype="multipart/form-data">
          {% csrf_token %}

          <h1>Label Descriptions</h1>
          <p>This section lets you update your label descriptions.</p>
          <table class="table">
            {{ label_descriptions.management_form }}
            {{ label_descriptions.non_form_errors }}
            <thead>
              <th>Label</th>
              <th>Description</th>
            </thead>
            <tbody>
            {% for form in label_descriptions.forms %}
            <tr>
            {% for field in form.hidden_fields %}
              {{ field }}
            {% endfor %}
            {% for field in form.visible_fields %}
              <td>{{ field }}</td>
            {% endfor %}
            </tr>
            {% endfor %}
          </tbody>
          </table>
          <div class="form-group">
            <button class="btn btn-primary" type="submit">Submit</button>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>
{% endblock %}

{% block scripts_body %}
<script type="text/javascript">
$('.formset_row_label').formset({
  addText: 'add label',
  deleteText: 'remove label',
  prefix: '{{ labels.prefix }}',
  added: function () {
    // Reset drop down and errors from both columns when adding new rows
    $('tr.formset_row_label').last().children(':first').find('ul.errorlist li').empty();
  }
});
</script>
{% endblock %}
